<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/toOneList' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>借贷管理</el-breadcrumb-item>
      <el-breadcrumb-item>借贷审核</el-breadcrumb-item>
      <el-breadcrumb-item>新增标</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <el-button @click="check()" style="margin-bottom: 20px">查看借款信息</el-button>
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-row>
          <el-col :span="12">
            <el-form-item label="标名:" prop="name" >
              <el-input v-model="obj.bidName" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="标签:" prop="name" >
              <el-input v-model="obj01.tag" ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="标的类型:" prop="region">
              <el-select v-model="obj01.bidType" placeholder="请选择活动区域">
                <el-option label="无" :value=0></el-option>
                <el-option label="房抵" :value=1></el-option>
                <el-option label="车抵" :value=2></el-option>
                <el-option label="民品抵" :value=3></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="递增金额:" prop="region">
              <el-select v-model="obj01.incrAmount" placeholder="请选择活动区域">
                <el-option label="500" value="500"></el-option>
                <el-option label="1000" value="1000"></el-option>
                <el-option label="1500" value="1500"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="最低起投金额:" prop="name" style="width: 50%">
              <el-input v-model="obj01.minAmount" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="最大可投金额:" prop="name" style="width: 50%">
              <el-input v-model="obj01.maxAmount" ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="计息的方式:" prop="resource">
              <!--          0：成交日 1：T+1 2: T+2 3: 成立计息-->
              <el-radio-group v-model="obj01.interestMode">
                <el-radio label="0" >成交日</el-radio>
                <el-radio label="1" >T+1 </el-radio>
                <el-radio label="2" >T+2</el-radio>
                <el-radio label="3" >成立计息</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="募集类型:" prop="region">
              <el-select v-model="obj01.raiseType" placeholder="请选择活动区域">
                <el-option label="天" value="0"></el-option>
                <el-option label="小时" value="1"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="募集时长(天/小时):" prop="desc">
              <el-input type="textarea" v-model="obj01.raiseNum"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="开售时间:">
              <el-date-picker v-model="obj01.openTime" type="date" placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="项目介绍:" prop="desc">
              <el-input type="textarea" v-model="obj01.proDesc"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="风控措施:" prop="desc">
              <el-input type="textarea" v-model="obj01.rcms"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item>
          <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
          <el-button @click="resetForm('ruleForm')">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>
    {{obj01}}
  </div>

</template>

<script>
  export default {
    name: 'addbiao',
    data(){
      return{
        obj01:{bidType:''},
        id:null,//借款信息的id
        obj:{},//借款信息对象
        obj02:{},//借款信息的担保对象
        ruleForm: {
          name: '',
          region: '',
          date1: '',
          date2: '',
          delivery: false,
          type: [],
          resource: '',
          desc: ''
        },
        rules: {
          // name: [
          //   { required: true, message: '请输入活动名称', trigger: 'blur' },
          //   { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
          // ],
          // region: [
          //   { required: true, message: '请选择活动区域', trigger: 'change' }
          // ],
          // date1: [
          //   { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
          // ],
          // date2: [
          //   { type: 'date', required: true, message: '请选择时间', trigger: 'change' }
          // ],
          // type: [
          //   { type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change' }
          // ],
          // resource: [
          //   { required: true, message: '请选择活动资源', trigger: 'change' }
          // ],
          // desc: [
          //   { required: true, message: '请填写活动形式', trigger: 'blur' }
          // ]
        }
      };
    },
    methods:{
      check:function(id){
        this.$router.push({path:"/updateloan",query:{id:this.$route.query.id,type:'check'}});
      },
      updatestate:function(id,val){ //状态修改
        this.$http.post("/finance-service-borrowing/loan/updatestate/"+id+"/"+val).then((res)=>{
            if(res.data.success){
              this.$message({
                type: 'success',
                message: res.data.message
              });
              // this.sel01();
            }else {
              this.$message({
                type: 'error',
                message: res.data.message
              });
            }
          }
        )
      },
      toadd:function(){//添加
        this.obj01.raiseAmount=0;
        this.$http.post("/finance-service-borrowing/ebankbidinfo/toadd",this.obj01).then(res=>{
          if(res.data.success){
            this.updatestate(this.obj.id,4);
            this.$router.push("/biaoup")
          }
        })
      },
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('submit!');

            this.toadd();
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      },
      //借款信息对象
      findone:function () {//查询借款信息对象
        this.$http.post("/finance-service-borrowing/loan/findone/"+this.id).then((res)=>{
            this.obj=res.data.result;
          this.obj01.bidName = this.obj.bidName
          this.obj01.lid = this.obj.id
              this.$http.post("/finance-service-borrowing/mg/findonegrtId/"+this.obj.id).then((res)=> {//查询借款信息的担保对象
                debugger;
                this.obj02 = res.data.result;
                this.obj01.bidType =res.data.result.type
              })
          }
        )
      }
    },
    mounted () {
      this.id = this.$route.query.id;//标的id
      this.findone();//查询借款信息对象
    }
  }
</script>

<style scoped>

</style>
